package com.example.pingze.utils;


import com.example.pingze.vo.Result;

//该静态方法用于指定登陆成功后返回的数据格式方便前端对数据的解析
public class ResultVOUtils {
    //将执行后的信息返回给前端
    public static<T> Result success(String msg){
        Result<T> result = new Result<T>();
        result.setCode("200");
        result.setMsg(msg);
        result.setData(null);
        return result;
    }
    //将执行后的数据返回给前端
    public static<T> Result result(T data){
        Result<T> result = new Result<T>();
        result.setCode("200");
        result.setMsg("成功");
        result.setData(data);
        return result;
    }
    //将异常通过Result方式抛给前端
    public static<T> Result error(String msg){
        Result<T> result = new Result<T>();
        result.setCode("250");
        result.setMsg(msg);
        result.setData(null);
        return result;
    }
}
